import 'package:flutter/material.dart';


class CommonTag extends StatelessWidget {
  final String title;
  final Color color;
  final Color bakckgroundColor;

  const CommonTag.origin(this.title,{Key key, this.color=Colors.black, this.bakckgroundColor=Colors.black12}) : super(key: key);
 
 factory CommonTag(String title){
   switch (title) {
     case "近地铁":
       return CommonTag.origin(
         title,
         color: Colors.blue,
         bakckgroundColor: Colors.blue[50],
         );
       
        case "集中供暖":
       return CommonTag.origin(
         title,
         color: Colors.blue,
         bakckgroundColor: Colors.blue[50],
         );
       
        case "随时看房":
       return CommonTag.origin(
         title,
         color: Colors.red,
         bakckgroundColor: Colors.red[50],
         );
     
        case "新上":
       return CommonTag.origin(
         title,
         color: Colors.red,
         bakckgroundColor: Colors.red[50],
         );
     
     default:
        return CommonTag.origin(title);
   }
 }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(4),
      padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
      decoration: BoxDecoration(
        color: bakckgroundColor,
        borderRadius: BorderRadius.circular(8)
      ),
      child: Text(title,style: TextStyle(fontSize: 10,color: color),),
    );
  }
}